package j_composite.a_design_pattern;

/**
 * Created by wug on 2016/7/14 0014.
 * 抽象组件
 */
public abstract class Component {
    //名称
    protected String name;

    /**
     * 一些操作
     */
    public abstract void operation();

    /**
     * 添加
     * @param component
     * @return
     */
    public abstract Component add(Component component);

    /**
     * 移除
     * @param component
     * @return
     */
    protected abstract Component remove(Component component);

    /**
     * 获取指定位置的组件
     * @param i
     * @return
     */
    protected abstract Component getChild(int i);

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
